package com.ququ.syb.business.channel.controller;

import com.ququ.common.result.Result;
import com.ququ.syb.business.channel.service.PayChannelService;
import com.ququ.syb.common.pojo.PayChannel;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PayChannelController {
    @Autowired
    private PayChannelService payChannelService;

    @RequestMapping("/mychannels")
    public Result<List<PayChannel>> listMyPayChannels(@RequestParam String accountid,
                                                      @RequestParam String appcode){
        return new Result<>(payChannelService.listMyPayChannels(accountid,appcode));
    }

    @RequestMapping("/query")
    public Result<PayChannel> getPayChannel(@RequestParam String paychannelid,
                                            @RequestParam(required = false) String accountid,
                                            @RequestParam(required = false) String appcode){
        if (StringUtils.isBlank(accountid) && StringUtils.isBlank(appcode))
            return payChannelService.getPayChannel(paychannelid);
        else
            return payChannelService.getPayChannel(paychannelid, accountid, appcode);
    }

}
